# Table 7: Postal Voting


# 1. Load Packages ----

library(lfe)
library(stargazer)

# 2. Read in Data ----

load(file = "df_voxit_individual_props.RData")

load(file = "df_voxit_individual_analysis.RData")

# 3. Regressions ----
## 3.a Turnout ----

# Reg with Props>1
felm.props_all <- felm(turnout ~  utility_optc_sum + utility_optc_max + postal +
                         prop_voxit + male + married + age + uni + knowledge  + 
                         leftright +
                         initiative + initiative_counter + referendum_fak + 
                         referendum_comp | 
                         canton_id + year | 0 | canton_id + datum_merge, 
                       data = voxit_individual[voxit_individual$prop_voxit>1,])
summary(felm.props_all)

# Interaction Postal Voting
felm.postal <- felm(turnout ~ utility_optc_sum*postal + utility_optc_max*postal +
                      prop_voxit + male + married + age + uni + knowledge + 
                      leftright +
                      initiative + initiative_counter + referendum_fak + 
                      referendum_comp | 
                      canton_id + year | 0 | canton_id + datum_merge, 
                    data = voxit_individual[voxit_individual$prop_voxit>1,])
summary(felm.postal)

## 3.b Selective Abstention ----

# reg1
lm.eb_fec <- felm(empty_ballot ~ utility_optc + prop_nr_day + postal +
                    male + married + age + uni + knowledge + leftright | 
                    factor(typex) * factor(datum_merge) + canton_id | 0 | id + datum_merge, 
                  data = voxit_propositions[voxit_propositions$turnout==1,])
summary(lm.eb_fec)

# reg2
lm.postalx <- felm(empty_ballot ~ utility_optc*postal + prop_nr_day + 
                     male + married + age + uni + knowledge + leftright | 
                     factor(typex) * factor(datum_merge) + canton_id | 0 | id + datum_merge, 
                   data = voxit_propositions[voxit_propositions$turnout==1,])
summary(lm.postalx)


# 4. Regression Table ----
stargazer(felm.props_all, felm.postal, lm.eb_fec, lm.postalx,
          type = "latex",
          star.cutoffs = c(0.1, 0.05, 0.01),
          star.char = c("*", "**", "***"),
          summary=T,
          keep = c("utility_optc_sum", "utility_optc_max", "postal", 
                   "utility_optc_sum:postal", "postal:utility_optc_max",
                   "^utility_optc$", "prop_nr_day", "utility_optc:postal"),
          covariate.labels = c("U$^{sum}$", "U$^{max}$", 
                               "Postal", "U$^{sum}$*Postal", "U$^{max}$*Postal", 
                               "Net benefit U_{ij}", "Ballot position", 
                               "Net benefit U_{ij}*Postal"),
          order = c("^utility_optc_sum$", "^utility_optc_max$",
                    "^postal$", "^utility_optc_sum:postal$",
                    "^postal:utility_optc_max$",
                    "^utility_optc$", "^prop_nr_day$", "^utility_optc:postal$"),
          df = F,
          dep.var.caption="Dependent variable:",
          dep.var.labels = c("Turnout", "Selective abstention"),
          float = F, 
          omit.table.layout ="n",
          keep.stat = c("n"),
          out = "Table7.tex")
































